import { UnityEngine } from "csharp";

export interface GameObject extends UnityEngine.GameObject {
    JsAwake():void;
    JsStart():void;
    JsFixUpdate(delta:number):void;
    JsUpdate(delta:number):void;
    JsLateUpdate(delta:number):void;
    JsFinalize():void;
}

export interface GameEvents {
    Awake():void;
    Start():void;
    FixUpdate(delta:number):void;
    Update(delta:number):void;
    LateUpdate(delta:number):void;
    Finalize():void;
}

class JsBehaviour implements GameEvents{
    protected gameObject: GameObject;
    constructor(gameObject: GameObject){
        const _ts = this;
        _ts.gameObject = gameObject;
        _ts.gameObject.JsAwake = _ts.Awake.bind(_ts);
        _ts.gameObject.JsStart = _ts.Start.bind(_ts);
        _ts.gameObject.JsFixUpdate = _ts.FixUpdate.bind(_ts);
        _ts.gameObject.JsUpdate = _ts.Update.bind(_ts);
        _ts.gameObject.JsLateUpdate = _ts.LateUpdate.bind(_ts); 
        _ts.gameObject.JsFinalize = _ts.Finalize.bind(_ts);
    }
    Awake(){}
    Start(){}
    FixUpdate(delta:number){}
    Update(delta:number){}
    LateUpdate(delta:number){}
    Finalize(){}
}
export default JsBehaviour;